import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  resolve: {
    alias: {
      '@': '/src'
    }
  },

  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
    open:'/login'
  },

  plugins: [
    vue(),

    // 自动导入插件
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),

    // 自动注册组件插件
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
})
